#pragma once

#include "imgui/Layer.h"
#include "imgui/Editor.h"

namespace ImGui
{
	struct PathLabel
	{
		std::string m_FileName;
		std::string m_Path;
	};
	struct FileLabel
	{
		std::string m_Path;
		std::string m_FileName;
		std::string m_UpdateTime;
		unsigned long long m_FileSize;
		bool isDir;
	};

	struct FileDialog
	{
		ImGui::Editor m_Editor;

		std::string m_Path;
		int m_SelectRow = -1;
		bool m_ShouldChanged = false;
		std::string m_NewPath;
		std::string m_TargetFilename;
		bool m_OnSubmit=false;
		bool m_ShouldBack;

		std::vector<FileLabel> m_FileLabels;
		std::vector<PathLabel> m_PathLabels;


		FileDialog(const std::string& p = "./");
		void HandleFunc() ;
		void ViewFunc() ;
		void LoadChild();
		void SendSignal(const std::string& path);

		static std::string GetLastUpdateTime(const std::string& path);
		static bool IsRoot(const fs::path& p);

		std::string GetFullPath();
	};
};